<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        
        <ui:define name="title">
            <h:outputText value="#{bundle.ListEmployeeTitle}"></h:outputText>
        </ui:define>
        
        <ui:define name="body">
            
            <h:form>
                
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                
                <h:outputText escape="false" value="#{bundle.ListEmployeeEmpty}" rendered="#{employeeController.items.rowCount == 0}"/>
                <h:panelGrid columns="2">
                    
                    <h:outputLabel value="#{bundle.CreateEmployeeLabel_name}" for="name" />
                    <h:inputText id="name" value="#{employeeController.selected.name}" title="#{bundle.CreateEmployeeTitle_name}" required="true" requiredMessage="#{bundle.CreateEmployeeRequiredMessage_name}"/>
                    
                    <h:outputLabel value="#{bundle.CreateEmployeeLabel_userName}" for="userName" />
                    <h:inputText id="userName" value="#{employeeController.selected.userName}" title="#{bundle.CreateEmployeeTitle_userName}" required="true" requiredMessage="#{bundle.CreateEmployeeRequiredMessage_userName}"/>
                    
                   
                    <h:outputLabel value="#{bundle.CreateEmployeeLabel_phone}" for="phone" />
                    <h:inputText id="phone" value="#{employeeController.selected.phone}" title="#{bundle.CreateEmployeeTitle_phone}" />
                    
                    <h:outputLabel value="#{bundle.CreateEmployeeLabel_other}" for="other" />
                    <h:inputText id="other" value="#{employeeController.selected.other}" title="#{bundle.CreateEmployeeTitle_other}" />
                    
                    <h:outputLabel value="#{bundle.CreateEmployeeLabel_limits}" for="limits" />
                    <h:inputText id="limits" value="#{employeeController.selected.limits}" title="#{bundle.CreateEmployeeTitle_limits}" required="true" requiredMessage="#{bundle.CreateEmployeeRequiredMessage_limits}"/>
                
                </h:panelGrid>
                <br />
                <center>
                    <h:commandButton action="#{employeeController.create}" value="#{bundle.CreateEmployeeSaveLink}" class="btn btn-primary" />
                </center>
                
                
            </h:form>
            
            <h:form>
                <center><h1> عرض الموظفين </h1></center>
                <h:panelGroup rendered="#{employeeController.items.rowCount > 0}">
                    <p:dataTable value="#{employeeController.items}" var="item" 
                                 paginator="true" rows="10"  
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="10,20,30">
                        <f:facet name="header">  
                            كل الموظفين 
                        </f:facet>  
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListEmployeeTitle_name}"/>
                            </f:facet>
                            <h:outputText value="#{item.name}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListEmployeeTitle_userName}"/>
                            </f:facet>
                            <h:outputText value="#{item.userName}"/>
                        </p:column>
                        
                        
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListEmployeeTitle_phone}"/>
                            </f:facet>
                            <h:outputText value="#{item.phone}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListEmployeeTitle_other}"/>
                            </f:facet>
                            <h:outputText value="#{item.other}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListEmployeeTitle_limits}"/>
                            </f:facet>
                            <h:outputText value="#{item.limits}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandButton action="#{employeeController.prepareView}" value="#{bundle.ListEmployeeViewLink}" class="btn btn-primary"/>
                            <h:outputText value=" "/>
                            <h:commandButton action="#{employeeController.prepareEdit}" value="#{bundle.ListEmployeeEditLink}" class="btn btn-primary"/>
                            <h:outputText value=" "/>
                            <h:commandButton action="#{employeeController.destroy}" value="#{bundle.ListEmployeeDestroyLink}" class="btn btn-primary"/>
                             <h:outputText value=" "/>
                             <h:commandButton action="#{employeeController.Reset}" value="اعادة كلمت المرور" class="btn btn-primary"/>
                        </p:column>
                        
                    </p:dataTable>
                    
                </h:panelGroup>
                
            </h:form>
        </ui:define>
    </ui:composition>
</html>
